#ifndef MOTORCONTROL_H

#define MOTORCONTROL_H
#include "modbus.h"

#define MAXIMUM_SPEED 3000

#define  OPERATING_MODE  0x2000
#define  SPEED_SETTING  0x2001
#define  RUN_INSTRUCTION_SELECTION  0x2006
#define  VELOCITY_GIVEN_SELECTION  0x2007
#define  DRIVE_STATUS_WORD1 0x2100
#define  DRIVE_STATUS_WORD2 0x2101


typedef struct motorControl
{
    modbus_t *ctx;
    unsigned int speed;
    unsigned char model;
}MotorControl;

MotorControl* motorInit();
int motorRelease(MotorControl *motorCtrl);
int motorSetSpeed(MotorControl *motorCtrl,  unsigned short int speed);
unsigned short int  motorGetSpeed(MotorControl *mc);
int motorSetModel(MotorControl *motorCtrl, unsigned short int mode);
unsigned short int motorGetModel(MotorControl *motorCtrl);

#endif